using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using kxcxw.Data.Entities;

namespace kxcxw.Data.Mapping
{
	public class ActivityMap : EntityTypeConfiguration<Activity>
	{
        public ActivityMap()
		{
			// Primary Key
            this.HasKey(t => t.ActivityId);

			// Properties
            this.Property(t => t.ActivityId)
				.IsRequired()
				.HasMaxLength(36);
				
			this.Property(t => t.Title)
				.IsRequired()
				.HasMaxLength(150);
				
			this.Property(t => t.ImageName)
				.IsRequired()
				.HasMaxLength(150);

            this.Property(t => t.ShopUrl)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.UserID)
                .IsRequired()
                .HasMaxLength(36);
				
			// Table & Column Mappings
            this.ToTable("Activity");
            this.Property(t => t.ActivityId).HasColumnName("ActivityId");
            this.Property(t => t.Title).HasColumnName("Title");
            this.Property(t => t.ShopType).HasColumnName("ShopType");
            this.Property(t => t.BusinessName).HasColumnName("BusinessName");
            this.Property(t => t.Address).HasColumnName("Address");
            this.Property(t => t.Phone).HasColumnName("Phone");
            this.Property(t => t.ShopUrl).HasColumnName("ShopUrl");
            this.Property(t => t.ImageName).HasColumnName("ImageName");
            this.Property(t => t.StartDate).HasColumnName("StartDate");
            this.Property(t => t.EndDate).HasColumnName("EndDate");
            this.Property(t => t.Desception).HasColumnName("Desception");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.UserID).HasColumnName("UserID");
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");

            //this.HasOptional(t => t.SysUserInfo)
            //    .WithMany(t => t.Activitys)
            //    .HasForeignKey(d => d.UserID);

            // Relationships
		}
	}
}

